Skip to content

feat(storage): adopt the NanoKVM Go file-manager UI - #982

Merged
916BGAI merged 1 commit into
sipeed:mainfrom
liangzhuohua:feat/storage-file-manager-ui
Nov 6, 2026
Merged

916BGAI merged 1 commit into
sipeed:mainfrom
liangzhuohua:feat/storage-file-manager-ui

Conversation

@liangzhuohua

Copy link
Copy Markdown
Collaborator

Summary

Reworks the storage surface to match NanoKVM Go: the menu entry is a picker with
two cards, "Disk mount" and "File sharing", that open their own windows, and file
sharing becomes a real file manager for the shared folder.

What changed

Storage menu

  • Two-card picker replaces the compact mount/eject popover.
  • The cards stay openable while the virtual disk is switched off: that switch is
    how the data partition is handed back for writing, so it is exactly the state an
    image upload starts from. Only the attach actions inside a window depend on the
    disk.

File manager (File sharing)

  • List and icon views (remembered per browser), sorting by name / size / type /
    modified time, search in the current folder, breadcrumbs and parent navigation.
  • Inline folder expansion, new folder, delete file or folder, download.
  • File uploads from the picker and by drag and drop, plus folder upload (picked
    or dropped): directories are created shallowest first and each file lands in its
    own directory. Empty folders are preserved on drop.
  • Disabled write actions say what to do: eject the virtual USB drive on the target
    machine, then turn off the Virtual Disk switch in Settings > Device.
  • Listing refresh: the storage push over the console socket when the account has
    it, a 3 s poll otherwise while the target machine owns the partition.

Disk mount

  • Mount mode picker, add media (upload / URL) and the image list.
  • Images only: unlike NanoKVM Go, this device has a single mass-storage LUN, so the
    shared folder is attached and released through the virtual disk switch.
  • The media job (a file written into the shared folder) is shown only in the file
    manager, so the mount window no longer reports transfers it did not start.

Server

  • POST /api/storage/media/files/mkdir with existsOk for recreating a tree, the
    same permission model as upload/delete, path validation, a symlinked-parent
    check, and a distinct error when the name is taken by a file.
  • localWritable in the media state. A /data left read-only while nothing is
    attached (a release whose remount failed, or the kernel remounting on an exFAT
    error) is now healed on the state poll and retried before any writable open or
    transfer; a heal that keeps failing is logged at most once a minute.
  • Static files: index.html revalidates on every load and hashed assets are
    immutable — but only while the file exists, so a 404 is never pinned for a year.
    An update can no longer be hidden by a cached document.
  • Keyboard forwarding skips events aimed at an input, textarea, select or
    contenteditable, so typing and pasting work in the new dialogs (same as NanoKVM
    Go).
  • MenuItem gains closeRequest, so a picker that opens a window closes without
    collapsing the menu bar.

Notes

  • "Already exists" is reported in the UI language through a new error code; other
    server messages stay English, as in NanoKVM Go.
  • Browsing inside a disk image is gone: NanoKVM Go's file manager is the shared
    folder only.
  • The ca, pt_br, se and tr strings for the new keys were written by the
    contributor; a native check would be welcome.

Testing

  • Frontend: tsc --noEmit, eslint (0 errors), vite build.
  • Server: go vet ./..., go test ./service/storage/... ./webcache/ (mkdir path
    and symlink cases, cache-header cases).
  • On device: menu picker, image mount/eject, URL download, local upload, folder
    upload with nested directories, create/delete, read-only state while the shared
    disk is attached, pasting into the URL and search fields.

Screenshots

possiblyneal pushed a commit to possiblyneal/NanoKVM-OS that referenced this pull request Nov 6, 2026
The user disk file manager in Settings > USB uploads a whole folder,
from the folder picker or dropped onto the file list, and dropped files
too. Folders are created shallowest first, empty ones included, then each
file goes into its own folder. A name that already exists or that FAT32
rejects is skipped and listed at the end, so uploading the same folder
again after an interruption continues where it stopped; disk-level errors
still stop the upload. The current path is now clickable breadcrumbs.

The server's mkdir takes existsOk=1: an existing folder of that name is
success, a file of that name is still an error.

Idea from sipeed/NanoKVM#982 (its file manager for the shared folder);
the code is ours, on our separate FAT32 user disk.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The storage entry becomes a picker with two windows: disk mounting and a
file manager for the shared folder, the way NanoKVM Go lays them out. The
cards stay openable while the virtual disk is switched off: that switch is
how the data partition is handed back for writing, so it is the state an
image upload starts from, and disabling the cards there would leave a new
device with no way to add its first image. Only the attach actions inside
the window depend on the disk.

The file manager gains list and icon views, sorting by name, size, type
and modified time, search, inline folder expansion, folder creation and
drag-and-drop uploads. It also uploads a whole folder, from the picker or
dropped onto the list: the folders are created shallowest first and every
file lands in its own directory, which is more than NanoKVM Go offers. A
dropped folder the browser cannot read is reported once instead of being
silently ignored.

A name that is already taken is answered with its own error code, so the
UI says "the file exists" in the user's language instead of showing the
server's English sentence, and the failed media job behind it is hidden
once the user has been told. The mount window keeps the mode picker and
the add media actions and lists images only: NanoKVM Go can keep its
shared disk always attached because it is a second LUN, while this device
has one, so the shared folder is attached and released by the virtual disk
switch.

Disabled write actions say what to do about it - eject the virtual USB
drive on the target machine, then turn off the Virtual Disk switch - the
same wording the NanoKVM Go build uses instead of a one-line refusal.

"The target machine is writing" is reported for the whole medium, so only
a zero-length entry touched in the last few seconds is labelled as an
upload in progress: an empty file from an hour ago is empty, not busy. The
same rule drives the list and the icon view.

The listing polls while the target machine owns the partition and the
account has no console socket to receive the storage push on, which is the
fallback the NanoKVM Go build uses for the same reason. The file manager
tells the watcher every directory it is showing - the one being listed and
every folder expanded - as a JSON list, so a folder name may contain a
comma. Because that set changes as the user navigates, the watcher
re-baselines without treating the new set as a write: counting it kept the
write quiet window alive forever, and zero-length files stayed labelled as
uploads that never finished. When the quiet window does end, the watcher
notifies once more for the same reason. An image listing leaves the set
alone; another browser may still be showing the shared folder.

The media job is polled and shown by the file manager alone: it reports a
file being written into the shared folder, so the mount window used to
show a transfer it had not started. Image transfers keep their own row.

The server grows POST /api/storage/media/files/mkdir, which the new folder
action and the folder upload need; it refuses names that exist (unless the
caller recreates a tree and says so) and refuses to create through a
symlinked parent. A name taken by a file is reported as such instead of
being mistaken for an existing folder.

A /data left read-only while nothing is attached - a release whose remount
failed, or the kernel remounting on an exFAT error - used to turn every
upload, download and folder into an EROFS failure with no explanation. The
media state now carries localWritable, the state poll takes the partition
back when no medium owns it, and a writable open or transfer retries the
remount. A heal that keeps failing is reported at most once a minute, since
the poll would otherwise repeat it every few seconds.

Static files are labelled for the first time: the entry document
revalidates on every load and hashed assets are immutable - but only while
the file exists, so a 404 is never pinned for a year.

The keyboard forwarding skips events aimed at an input, textarea, select
or contenteditable, as the NanoKVM Go build does: cancelling the default
action is what kept a pasted URL out of the storage dialogs, and the new
file manager's search field needs the same. A key that was already
forwarded is still released when focus moves into such a field, and focus
entering one releases whatever the target machine was holding, so a
modifier cannot stay pressed over there. MenuItem gains closeRequest, so a
picker that opens a window closes without collapsing the menu bar.

Verified with pnpm build, go vet and go test.
@liangzhuohua
liangzhuohua force-pushed the feat/storage-file-manager-ui branch from 9f33949 to af8c0c4 Compare November 6, 2026 10:41
@916BGAI
916BGAI merged commit bb7194e into sipeed:main Nov 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants